<?php
namespace Siter\Controller;

class Controller extends \Think\Controller {
    protected $indexExpr = array(); //index方法关联的条件表达式
    protected $sortExpr  = '';      //排序表达式

    public function __construct() {
        parent::__construct();

        /**
         * 解析以application/json形式传递过来的数据
         */
        if($tmp = getJsonInput()) {
            $_POST = array_merge($_POST, $tmp);
        }
    }

    /**
     * _before_index 
     * 组装index方法的查询参数
     * 
     * @access public
     * @return void
     */
    public function _before_index() {
        try {
			$m          = D2(CONTROLLER_NAME);
			$searchJson = '';
			$expr       = array();

			if($search = $m->buildSearchExpr($_GET)) {
				$searchJson = $search['json'];
				$expr       = $search['expr'];
				$sortExpr   = $search['sort'];
			}
			if($searchTime = $m->searchTime($_GET)){
				$expr = array_merge($expr,$searchTime);
				
			}
			if(!empty($searchJson)) {
				$this->assign('searchJson', $searchJson);
			}

        $this->indexExpr = $expr;
        $this->sortExpr  = $sortExpr;
        } catch(\Exception $e) {
        }
    }

}
